home *** CD-ROM | disk | FTP | other *** search
- Path: news.mel.aone.net.au!usenet
- From: clyde@hitech.com.au (Clyde Smith-Stubbs)
- Newsgroups: comp.lang.c
- Subject: Re: HP UX 10.0 C programming
- Date: Thu, 04 Jan 1996 22:28:44 GMT
- Organization: HI-TECH Software
- Message-ID: <30ec5378.1252135360@news.bne.aone.net.au>
- References: <4cfje3$qk@nn.fast.net>
- Reply-To: clyde@hitech.com.au
- NNTP-Posting-Host: skyhawk.hitech.com.au
- X-Newsreader: Forte Agent .99c/16.141
-
- On 4 Jan 1996 04:01:07 GMT, "Chad R. Laity" <wick@pop.fast.net> wrote:
-
- > (2) Why do I get an error on this cut down program listed
- > below when I compile it on an HP 9000 K200 with HP UX 10.0
- > and I do not get an error with our Intergraph server?
-
- >#include <stdio.h>
- >#include <sys/stat.h>
- >
- >main()
- >{
- >int i;
- >int stat(const char *path, struct stat *buf); /****<<<--- GET RID OF THIS LINE ******/
- >
- >i = stat("/usr2/test/testfile", &buf); /* line 15 */
- >
- >}
-
- You should get rid of the declaration of stat() that you have embedded
- inside main(). Firstly, putting extern declarations inside functions
- is invariably a Bad Idea in C, even though it's technically legal. It
- uses the scoping rules of C to hide information from the compiler.
-
- Secondly, stat() is a system-defined function, and it has its
- prototype in <sys/stat.h> already - you should not redeclare it. Doing
- so is non-portable (as you just found out :-).
-
- Thirdly, I don't see a declaration for buf anywhere - add the line:
-
- struct stat buf;
-
- just inside the opening brace of main(). That should fix it.
-
- ----
- Clyde Smith-Stubbs | HI-TECH Software, | Voice: +61 7 3300 5011
- clyde@hitech.com.au | P.O. Box 103, Alderley, | Fax: +61 7 3300 5246
- http://www.hitech.com.au | QLD, 4051, AUSTRALIA. | BBS: +61 7 3300 5235
- ----------------------------------------------------------------------------
- FREE! Download our shareware (FREE for noncommercial use) MS-DOS C Compiler!
- Point your Web browser at http://www.hitech.com.au/
-